]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shell-global: Place launched applications into a systemd scope
authorBenjamin Berg <bberg@redhat.com>
Tue, 26 Nov 2019 18:45:29 +0000 (19:45 +0100)
committerBenjamin Berg <bberg@redhat.com>
Wed, 11 Dec 2019 08:34:36 +0000 (09:34 +0100)
This improves separation from the shells service scope for applications
launched using an XDG desktop file.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/863

meson.build
src/meson.build
src/shell-global.c

index d2f1271d60149ab6fdad29e567327c5b5741586e..5f6d050109c7e35bf43f8c0e21352d4c23eb8457 100644 (file)
@@ -30,6 +30,7 @@ polkit_req = '>= 0.100'
 schemas_req = '>= 3.33.1'
 startup_req = '>= 0.11'
 ibus_req = '>= 1.5.2'
+gnome_desktop_req = '>= 3.34.2'
 
 bt_req = '>= 3.9.0'
 gst_req = '>= 0.11.92'
@@ -95,6 +96,7 @@ startup_dep = dependency('libstartup-notification-1.0', version: startup_req)
 ibus_dep = dependency('ibus-1.0', version: ibus_req)
 x11_dep = dependency('x11')
 schemas_dep = dependency('gsettings-desktop-schemas', version: schemas_req)
+gnome_desktop_dep = dependency('gnome-desktop-3.0', version: gnome_desktop_req)
 
 bt_dep = dependency('gnome-bluetooth-1.0', version: bt_req, required: false)
 gst_dep = dependency('gstreamer-1.0', version: gst_req, required: false)
index 3523fb16cb3146f60545d70c51a9c5fc385ea332..cbf5886ea81e39dcd32690b41340c425f129b00d 100644 (file)
@@ -192,7 +192,7 @@ libshell_no_gir_sources += dbus_generated
 
 libshell = library('gnome-shell',
   sources: libshell_gir_sources + libshell_no_gir_sources,
-  dependencies: gnome_shell_deps + [libshell_menu_dep, libst_dep, mutter_dep, m_dep],
+  dependencies: gnome_shell_deps + [libshell_menu_dep, libst_dep, mutter_dep, gnome_desktop_dep, m_dep],
   include_directories: [conf_inc, st_inc, include_directories('tray')],
   c_args: gnome_shell_cflags,
   link_with: [libtray],
index 77e167c1079fafd1d3df283a2d4d65efaad174f9..05e632e2752187ca22735047b16eb11d0ccd5dca 100644 (file)
@@ -29,6 +29,9 @@
 #include <meta/meta-workspace-manager.h>
 #include <meta/meta-x11-display.h>
 
+#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <libgnome-desktop/gnome-systemd.h>
+
 /* Memory report bits */
 #ifdef HAVE_MALLINFO
 #include <malloc.h>
@@ -43,6 +46,7 @@
 #include "shell-perf-log.h"
 #include "shell-window-tracker.h"
 #include "shell-wm.h"
+#include "shell-util.h"
 #include "st.h"
 
 static ShellGlobal *the_object = NULL;
@@ -1308,6 +1312,30 @@ shell_global_get_current_time (ShellGlobal *global)
   return clutter_get_current_event_time ();
 }
 
+static void
+shell_global_app_launched_cb (GAppLaunchContext *context,
+                              GAppInfo          *info,
+                              GVariant          *platform_data,
+                              gpointer           user_data)
+{
+  gint32 pid;
+  const gchar *app_name;
+
+  if (!g_variant_lookup (platform_data, "pid", "i", &pid))
+    return;
+
+  app_name = g_app_info_get_id (info);
+  if (app_name == NULL)
+    app_name = g_app_info_get_executable (info);
+
+  /* Start async request; we don't care about the result */
+  gnome_start_systemd_scope (app_name,
+                             pid,
+                             NULL,
+                             NULL,
+                             NULL, NULL, NULL);
+}
+
 /**
  * shell_global_create_app_launch_context:
  * @global: A #ShellGlobal
@@ -1343,6 +1371,11 @@ shell_global_create_app_launch_context (ShellGlobal *global,
 
   meta_launch_context_set_workspace (context, ws);
 
+  g_signal_connect (context,
+                    "launched",
+                    G_CALLBACK (shell_global_app_launched_cb),
+                    NULL);
+
   return (GAppLaunchContext *) context;
 }